1613A - Long Comparison - CodeForces Solution


implementation math *900

Please click on ads to support us..

Python Code:

z = int(input())
def func():
    x1, p1 = map(int, input().split())
    x2, p2 = map(int, input().split())
    mn = min(p1,p2)
    p1-=mn
    p2-=mn
    if p1>=7:
        print(">")
    elif p2>=7:
        print("<")
    else:
        x1=x1*(10**p1)
        x2=x2*(10**p2)
        if x1<x2:
            print("<")
        elif x1>x2:
            print(">")
        else:
            print("=")
    
for i in range(z):
    func()

C++ Code:

// #include<bits/stdc++.h>
// using namespace std;
// int main(){
// ios_base::sync_with_stdio(false);
//  cin.tie(NULL);

// int t;
// cin>>t;
// while(t--){
// int a,c;
// int b,d;
// cin>>a>>c>>b>>d;

// for(int i=0;i<c;i++){
//     a=a*10;
// }
// for(int i=0;i<d;i++){
//     b=b*10;
// }

// if(a>b){
//     cout<<">"<<endl;
// }
// else if(a<b){
//    cout<<"<"<<endl;
// }
// else{
//     cout<<"="<<endl;
// }


// }
// return 0;
// }

#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
 cin.tie(NULL);

int t;
cin>>t;
while(t--){

int a,c;
int b,d;
cin>>a>>c>>b>>d;
int a1=a;
int b1=b;

int a2=0,b2=0;

while(a1){
    a1=a1/10;
    a2++;
}
while(b1){
    b1=b1/10;
    b2++;
}

if((c+a2)!=(d+b2)){
    if((c+a2)>(d+b2)){
        cout<<">"<<endl;
    }
    else{
        cout<<"<"<<endl;
    }
}
else{

   if(max(b2,a2)==a2){

    int y=(a2-b2);
    while(y--){
        b=b*10;
    }

   }
   else{
     int y=(b2-a2);
    while(y--){
        a=a*10;
    }

   }
if(a>b){
    cout<<">"<<endl;
}
else if(a<b){
   cout<<"<"<<endl;
}
else{
    cout<<"="<<endl;
}
   
  
}




}
return 0;
}


Comments

Submit
0 Comments
More Questions

1038A - Equality
1061A - Coins
1676E - Eating Queries
1447A - Add Candies
1721D - Maximum AND
363C - Fixing Typos
1401A - Distance and Axis
658A - Bear and Reverse Radewoosh
1721E - Prefix Function Queries
977E - Cyclic Components
1140D - Minimum Triangulation
75C - Modified GCD
1722A - Spell Check
1722B - Colourblindness
1722D - Line
1722C - Word Game
1722G - Even-Odd XOR
552E - Vanya and Brackets
933A - A Twisty Movement
1722F - L-shapes
1196B - Odd Sum Segments
1325D - Ehab the Xorcist
552B - Vanya and Books
1722E - Counting Rectangles
168A - Wizards and Demonstration
168B - Wizards and Minimal Spell
7A - Kalevitch and Chess
912B - New Year's Eve
1537C - Challenging Cliffs
879B - Table Tennis